import request from '/@/utils/request';
import { paramsSerializer } from '/@/utils/sort';

// 用户列表
export const adminList = (params?: object) => {
  return request({
    url: 'api/v1/admins/admin',
    method: 'get',
    params,
    paramsSerializer
  })
}

// 用户详情
export const adminDetail = (id: number) => {
  return request({
    url: `api/v1/admins/admin/${id}`,
    method: 'get',
  })
}

// 用户详情
export const adminInfo = (name: string) => {
  return request({
    url: `api/v1/admins/adminInfo?name=${name}`,
    method: 'get',
  })
}

// 新增用户
export const addAdmin = (data: Object) => {
  return request({
    url: `api/v1/admins/admin`,
    method: 'post',
    data
  })
}

// 修改用户
export const updateAdmin = (data: Object) => {
  return request({
    url: `api/v1/admins/admin`,
    method: 'put',
    data
  })
}

// 删除用户
export const deleteAdmin = (id: number) => {
  return request({
    url: `api/v1/admins/admin/${id}`,
    method: 'delete'
  })
}

// 登录
export const login = (data: Object) => {
  return request({
    url: `api/v1/admins/login`,
    method: 'post',
    data
  })
}
